 /* Copyright 2018 JDCLOUD.COM

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http:#www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

JCLOUD MONITOR API
monitor API

OpenAPI spec version: v2
Contact: 

NOTE: This class is auto generated by the jdcloud code generator program.
*/


#import <Foundation/Foundation.h>
#import <JDCloudOCSDKMonitor/MonitorExecutor.h>

@implementation MonitorClient

@synthesize userAgent = _userAgent;
@synthesize serviceName = _serviceName;
@synthesize version = _version;

-(void) addCustomerHeaderWithKey:(NSString*) key
                           value:(NSString*) value{
    if(![self customHeader])
    {
        self.customHeader = [[NSMutableDictionary alloc] init];
    }
    if(key && value)
    {
        [[self customHeader] setValue:value forKey:key];
    }
   
}

-(id)initWithGlobalConfig{
    if(![GlobalConfig credential])
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@"GlobalConfig credential not config" userInfo:nil];
        @throw e;
    }
    self.credential = [GlobalConfig credential];
    if(![GlobalConfig sdkEnvironment])
    {
        self.sdkEnvironment = [[SDKEnvironment alloc] initWithEndPoint:@"monitor.jdcloud-api.com"];
    }else
    {
        self.sdkEnvironment = [GlobalConfig sdkEnvironment];
    }
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 monitor  v2";
    _serviceName = @"monitor";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}

-(id)initWithCredential:(Credential*)credential
         sdkEnvironment:(SDKEnvironment*)sdkEnvironment
{
    if(!credential)
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@" credential can not null" userInfo:nil];
        @throw e;
    }else{
        self.credential = credential;
    }
    
    if(!sdkEnvironment)
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@" sdkEnvironment can not null" userInfo:nil];
        @throw e;
    }else{
        self.sdkEnvironment = sdkEnvironment;
    }
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 monitor  v2";
    _serviceName = @"monitor";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}

-(id)initWithCredential:(Credential*)credential
{
    if(!credential)
    {
        NSException *e = [SDKArgumentNullException exceptionWithName:@"ArgumentNullException" reason:@" credential can not null" userInfo:nil];
        @throw e;
    }else{
        self.credential = credential;
    }
    if(![GlobalConfig sdkEnvironment])
    {
        self.sdkEnvironment = [[SDKEnvironment alloc] initWithEndPoint:@"monitor.jdcloud-api.com"];
    }else
    {
        self.sdkEnvironment = [GlobalConfig sdkEnvironment];
    }
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 monitor  v2";
    _serviceName = @"monitor";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}

-(id)init{
    self.httpRequestProtocol = @"https";
    _userAgent = @"JdCloudOCSdk 0.0.1 monitor  v2";
    _serviceName = @"monitor";
    _version = @"v2";
    self.contentType = @"application/json";
    return self;
}


/**
describeMetricData sync request
@param describeMetricDataRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeMetricDataResponse` the request response data model
*/
-(NSDictionary*) describeMetricDataSyncWithRequest:(MonitorDescribeMetricDataRequest*) describeMetricDataRequest
{
MonitorDescribeMetricDataExecutor* excutor = [[MonitorDescribeMetricDataExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeMetricDataRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeMetricDataResponse* response = [[MonitorDescribeMetricDataResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeMetricDataResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeMetricDataAsyncWithRequest:(MonitorDescribeMetricDataRequest*) describeMetricDataRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeMetricDataResponse* _Nullable describeMetricDataResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeMetricDataExecutor* excutor = [[MonitorDescribeMetricDataExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeMetricDataRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeMetricDataResponse* response = [[MonitorDescribeMetricDataResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
createAlarm sync request
@param createAlarmRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `createAlarmResponse` the request response data model
*/
-(NSDictionary*) createAlarmSyncWithRequest:(MonitorCreateAlarmRequest*) createAlarmRequest
{
MonitorCreateAlarmExecutor* excutor = [[MonitorCreateAlarmExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:createAlarmRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorCreateAlarmResponse* response = [[MonitorCreateAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"createAlarmResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)createAlarmAsyncWithRequest:(MonitorCreateAlarmRequest*) createAlarmRequest
                       completionHandler:(void(^)(int statusCode,MonitorCreateAlarmResponse* _Nullable createAlarmResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorCreateAlarmExecutor* excutor = [[MonitorCreateAlarmExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:createAlarmRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorCreateAlarmResponse* response = [[MonitorCreateAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeServices sync request
@param describeServicesRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeServicesResponse` the request response data model
*/
-(NSDictionary*) describeServicesSyncWithRequest:(MonitorDescribeServicesRequest*) describeServicesRequest
{
MonitorDescribeServicesExecutor* excutor = [[MonitorDescribeServicesExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeServicesRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeServicesResponse* response = [[MonitorDescribeServicesResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeServicesResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeServicesAsyncWithRequest:(MonitorDescribeServicesRequest*) describeServicesRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeServicesResponse* _Nullable describeServicesResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeServicesExecutor* excutor = [[MonitorDescribeServicesExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeServicesRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeServicesResponse* response = [[MonitorDescribeServicesResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeMetricsForAlarm sync request
@param describeMetricsForAlarmRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeMetricsForAlarmResponse` the request response data model
*/
-(NSDictionary*) describeMetricsForAlarmSyncWithRequest:(MonitorDescribeMetricsForAlarmRequest*) describeMetricsForAlarmRequest
{
MonitorDescribeMetricsForAlarmExecutor* excutor = [[MonitorDescribeMetricsForAlarmExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeMetricsForAlarmRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeMetricsForAlarmResponse* response = [[MonitorDescribeMetricsForAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeMetricsForAlarmResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeMetricsForAlarmAsyncWithRequest:(MonitorDescribeMetricsForAlarmRequest*) describeMetricsForAlarmRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeMetricsForAlarmResponse* _Nullable describeMetricsForAlarmResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeMetricsForAlarmExecutor* excutor = [[MonitorDescribeMetricsForAlarmExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeMetricsForAlarmRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeMetricsForAlarmResponse* response = [[MonitorDescribeMetricsForAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeAlarmContacts sync request
@param describeAlarmContactsRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeAlarmContactsResponse` the request response data model
*/
-(NSDictionary*) describeAlarmContactsSyncWithRequest:(MonitorDescribeAlarmContactsRequest*) describeAlarmContactsRequest
{
MonitorDescribeAlarmContactsExecutor* excutor = [[MonitorDescribeAlarmContactsExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeAlarmContactsRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmContactsResponse* response = [[MonitorDescribeAlarmContactsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeAlarmContactsResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeAlarmContactsAsyncWithRequest:(MonitorDescribeAlarmContactsRequest*) describeAlarmContactsRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeAlarmContactsResponse* _Nullable describeAlarmContactsResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeAlarmContactsExecutor* excutor = [[MonitorDescribeAlarmContactsExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeAlarmContactsRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmContactsResponse* response = [[MonitorDescribeAlarmContactsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeAlarmHistory sync request
@param describeAlarmHistoryRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeAlarmHistoryResponse` the request response data model
*/
-(NSDictionary*) describeAlarmHistorySyncWithRequest:(MonitorDescribeAlarmHistoryRequest*) describeAlarmHistoryRequest
{
MonitorDescribeAlarmHistoryExecutor* excutor = [[MonitorDescribeAlarmHistoryExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeAlarmHistoryRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmHistoryResponse* response = [[MonitorDescribeAlarmHistoryResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeAlarmHistoryResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeAlarmHistoryAsyncWithRequest:(MonitorDescribeAlarmHistoryRequest*) describeAlarmHistoryRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeAlarmHistoryResponse* _Nullable describeAlarmHistoryResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeAlarmHistoryExecutor* excutor = [[MonitorDescribeAlarmHistoryExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeAlarmHistoryRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmHistoryResponse* response = [[MonitorDescribeAlarmHistoryResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeAlarm sync request
@param describeAlarmRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeAlarmResponse` the request response data model
*/
-(NSDictionary*) describeAlarmSyncWithRequest:(MonitorDescribeAlarmRequest*) describeAlarmRequest
{
MonitorDescribeAlarmExecutor* excutor = [[MonitorDescribeAlarmExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeAlarmRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmResponse* response = [[MonitorDescribeAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeAlarmResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeAlarmAsyncWithRequest:(MonitorDescribeAlarmRequest*) describeAlarmRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeAlarmResponse* _Nullable describeAlarmResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeAlarmExecutor* excutor = [[MonitorDescribeAlarmExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeAlarmRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmResponse* response = [[MonitorDescribeAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
lastDownsample sync request
@param lastDownsampleRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `lastDownsampleResponse` the request response data model
*/
-(NSDictionary*) lastDownsampleSyncWithRequest:(MonitorLastDownsampleRequest*) lastDownsampleRequest
{
MonitorLastDownsampleExecutor* excutor = [[MonitorLastDownsampleExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:lastDownsampleRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorLastDownsampleResponse* response = [[MonitorLastDownsampleResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"lastDownsampleResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)lastDownsampleAsyncWithRequest:(MonitorLastDownsampleRequest*) lastDownsampleRequest
                       completionHandler:(void(^)(int statusCode,MonitorLastDownsampleResponse* _Nullable lastDownsampleResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorLastDownsampleExecutor* excutor = [[MonitorLastDownsampleExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:lastDownsampleRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorLastDownsampleResponse* response = [[MonitorLastDownsampleResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
deleteAlarms sync request
@param deleteAlarmsRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `deleteAlarmsResponse` the request response data model
*/
-(NSDictionary*) deleteAlarmsSyncWithRequest:(MonitorDeleteAlarmsRequest*) deleteAlarmsRequest
{
MonitorDeleteAlarmsExecutor* excutor = [[MonitorDeleteAlarmsExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:deleteAlarmsRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDeleteAlarmsResponse* response = [[MonitorDeleteAlarmsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"deleteAlarmsResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)deleteAlarmsAsyncWithRequest:(MonitorDeleteAlarmsRequest*) deleteAlarmsRequest
                       completionHandler:(void(^)(int statusCode,MonitorDeleteAlarmsResponse* _Nullable deleteAlarmsResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDeleteAlarmsExecutor* excutor = [[MonitorDeleteAlarmsExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:deleteAlarmsRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDeleteAlarmsResponse* response = [[MonitorDeleteAlarmsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeProductsForAlarm sync request
@param describeProductsForAlarmRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeProductsForAlarmResponse` the request response data model
*/
-(NSDictionary*) describeProductsForAlarmSyncWithRequest:(MonitorDescribeProductsForAlarmRequest*) describeProductsForAlarmRequest
{
MonitorDescribeProductsForAlarmExecutor* excutor = [[MonitorDescribeProductsForAlarmExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeProductsForAlarmRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeProductsForAlarmResponse* response = [[MonitorDescribeProductsForAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeProductsForAlarmResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeProductsForAlarmAsyncWithRequest:(MonitorDescribeProductsForAlarmRequest*) describeProductsForAlarmRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeProductsForAlarmResponse* _Nullable describeProductsForAlarmResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeProductsForAlarmExecutor* excutor = [[MonitorDescribeProductsForAlarmExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeProductsForAlarmRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeProductsForAlarmResponse* response = [[MonitorDescribeProductsForAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
updateAlarm sync request
@param updateAlarmRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `updateAlarmResponse` the request response data model
*/
-(NSDictionary*) updateAlarmSyncWithRequest:(MonitorUpdateAlarmRequest*) updateAlarmRequest
{
MonitorUpdateAlarmExecutor* excutor = [[MonitorUpdateAlarmExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:updateAlarmRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorUpdateAlarmResponse* response = [[MonitorUpdateAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"updateAlarmResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)updateAlarmAsyncWithRequest:(MonitorUpdateAlarmRequest*) updateAlarmRequest
                       completionHandler:(void(^)(int statusCode,MonitorUpdateAlarmResponse* _Nullable updateAlarmResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorUpdateAlarmExecutor* excutor = [[MonitorUpdateAlarmExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:updateAlarmRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorUpdateAlarmResponse* response = [[MonitorUpdateAlarmResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
enableAlarms sync request
@param enableAlarmsRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `enableAlarmsResponse` the request response data model
*/
-(NSDictionary*) enableAlarmsSyncWithRequest:(MonitorEnableAlarmsRequest*) enableAlarmsRequest
{
MonitorEnableAlarmsExecutor* excutor = [[MonitorEnableAlarmsExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:enableAlarmsRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorEnableAlarmsResponse* response = [[MonitorEnableAlarmsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"enableAlarmsResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)enableAlarmsAsyncWithRequest:(MonitorEnableAlarmsRequest*) enableAlarmsRequest
                       completionHandler:(void(^)(int statusCode,MonitorEnableAlarmsResponse* _Nullable enableAlarmsResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorEnableAlarmsExecutor* excutor = [[MonitorEnableAlarmsExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:enableAlarmsRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorEnableAlarmsResponse* response = [[MonitorEnableAlarmsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
putMetricData sync request
@param putMetricDataRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `putMetricDataResponse` the request response data model
*/
-(NSDictionary*) putMetricDataSyncWithRequest:(MonitorPutMetricDataRequest*) putMetricDataRequest
{
MonitorPutMetricDataExecutor* excutor = [[MonitorPutMetricDataExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:putMetricDataRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorPutMetricDataResponse* response = [[MonitorPutMetricDataResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"putMetricDataResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)putMetricDataAsyncWithRequest:(MonitorPutMetricDataRequest*) putMetricDataRequest
                       completionHandler:(void(^)(int statusCode,MonitorPutMetricDataResponse* _Nullable putMetricDataResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorPutMetricDataExecutor* excutor = [[MonitorPutMetricDataExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:putMetricDataRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorPutMetricDataResponse* response = [[MonitorPutMetricDataResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeMetrics sync request
@param describeMetricsRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeMetricsResponse` the request response data model
*/
-(NSDictionary*) describeMetricsSyncWithRequest:(MonitorDescribeMetricsRequest*) describeMetricsRequest
{
MonitorDescribeMetricsExecutor* excutor = [[MonitorDescribeMetricsExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeMetricsRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeMetricsResponse* response = [[MonitorDescribeMetricsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeMetricsResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeMetricsAsyncWithRequest:(MonitorDescribeMetricsRequest*) describeMetricsRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeMetricsResponse* _Nullable describeMetricsResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeMetricsExecutor* excutor = [[MonitorDescribeMetricsExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeMetricsRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeMetricsResponse* response = [[MonitorDescribeMetricsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}

/**
describeAlarms sync request
@param describeAlarmsRequest request param
@return key `statusCode` http request status code type is int
            `dataResult` the http request response data  type is NSData
            `requestError` the request error type is NSError
            `describeAlarmsResponse` the request response data model
*/
-(NSDictionary*) describeAlarmsSyncWithRequest:(MonitorDescribeAlarmsRequest*) describeAlarmsRequest
{
MonitorDescribeAlarmsExecutor* excutor = [[MonitorDescribeAlarmsExecutor alloc] initWithJDCloudClient:self];
    NSDictionary* responseResult = [excutor executeSync:describeAlarmsRequest];
    if(responseResult)
    {
        NSData * resultData = [[responseResult objectForKey:@"dataResult"] copy];
        if(resultData)
        {
            NSMutableDictionary* result = [[NSMutableDictionary alloc]initWithDictionary:responseResult];
            
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmsResponse* response = [[MonitorDescribeAlarmsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        [result setValue:response forKey:@"describeAlarmsResponse"];
                        return result;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
    }
    return responseResult;
}


-(void)describeAlarmsAsyncWithRequest:(MonitorDescribeAlarmsRequest*) describeAlarmsRequest
                       completionHandler:(void(^)(int statusCode,MonitorDescribeAlarmsResponse* _Nullable describeAlarmsResponse, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
MonitorDescribeAlarmsExecutor* excutor = [[MonitorDescribeAlarmsExecutor alloc] initWithJDCloudClient:self];
    [excutor executeAsync:describeAlarmsRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        if(!error&&responseData)
        {
            NSData * resultData = [responseData copy];
            NSError *jsonError;
            NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:resultData options:0 error:&jsonError];
            if(!jsonError&& allKeys)
            {
                @try {
                    MonitorDescribeAlarmsResponse* response = [[MonitorDescribeAlarmsResponse alloc]initWithDic:allKeys];
                    if(response)
                    {
                        completionHandler(statusCode,response,responseData,error);
                        return;
                    }
                } @catch (NSException *exception) {
                    if([GlobalConfig isDebug]){
                        NSLog(@"json serialize response data error,info is %@",exception.reason);
                    }
                }
            }
        }
        completionHandler(statusCode,nil,responseData,error);
    }];
}


 /**
 monitor common sync request
 @param  jdcloudDataRequest request param
 @return key `statusCode` http request status code type is int
             `dataResult` the http request response data  type is NSData
             `requestError` the request error type is NSError
 */
 -(NSDictionary*) monitorCommonSyncWithRequest:(JDCloudDataRequest*) jdcloudDataRequest
                                                   url:(NSString*) url
                                                method:(NSString*) method{
    CommonExecutor* excutor = [[CommonExecutor alloc] initWithJDCloudClient:self url:url method:method];
    NSDictionary* responseResult = [excutor executeDataSync:jdcloudDataRequest];
    return responseResult;
}

-(void)monitorCommonAsyncWithRequest:(JDCloudDataRequest*) jdcloudDataRequest
                                         url:(NSString*) url
                                      method:(NSString*) method
                           completionHandler:(void(^)(int statusCode, NSData* _Nullable responseData,NSError * _Nullable error))completionHandler
{
     CommonExecutor* excutor = [[CommonExecutor alloc] initWithJDCloudClient:self url:url method:method];
    
    [excutor executeDataAsync:jdcloudDataRequest completionHandler:^(int statusCode, NSData * _Nullable responseData, NSError * _Nullable error) {
        completionHandler(statusCode,responseData,error);
    }];
} 

@end
